<?php
$a=0;
$b=0; 
$d=0;
$e=array();
if(!empty($_GET)){
    $a=$_GET['num1'];
     $b=$_GET['num2'];
      $c=$_GET['fh'];
      switch ($c){
          case '+':
              $c='+'?$e['1']='selected=""': $e['1']='';
           $d=$a+$b;
           break;
          case '-':
              $c='+'?$e['2']='selected=""': $e['2']='';
           $d=$a-$b;
           break;
          case '*':
              $c='+'?$e['3']='selected=""': $e['3']='';
           $d=$a*$b;
           break;
          case '/':
              $c='+'?$e['4']='selected=""': $e['4']='';
           $d=$a/$b;
           break;
       default :
           $d='';
           $e='';
      }
}
?>

<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
  <!-- <script  type="text/javascript">
        var a=window.prompt('请输入第一个数');
        var b=window.prompt('请输入第二个数');
        var c=window.prompt('请输入运算符');
        if(c==="+"){
            window.alert(a+b);
        }else if(c === "-"){
            window.alert(a-b);
        }else if(c ==="*"){
            window.alert(a*b);
        }else if(c === "/"){
            window.alert(a/b);
        }
    </script>--> 
    <body>
        <div>
            <form method="get" action="test.php">
              <input type="text" name="num1" value='<?php echo $a ?>' />
              <select name='fh' >
                  <option value="+" <?echo !empty($e['1'])?$e['1'] : '' ?> >+</option>
                  <option value="-"  <?echo !empty($e['2'])?$e['2'] : '' ?>  >-</option>
                  <option vlaue="*" <?echo !empty($e['3'])?$e['3'] : '' ?> >*</option>
                  <option vlaue="/"  <?echo !empty($e['4'])?$e['4'] : '' ?> >/</option>
              </select>
              <input type="text" name="num2" value='<?php echo $b ?>'/>
              <input type="submit" value="=" />
            </from>
             <input type="text" name="num3" value=' <?php echo $d ?>'/>
           
        </div>
    </body>
</html>
